const path = require('path')
const webpack = require('webpack')
const { merge } = require('webpack-merge')
const common = require('./webpack.common')

module.exports = merge(common, {
  // 开发模式
  mode: 'development',
  // 设置 source map
  devtool: 'cheap-module-eval-source-map',
  // 设置开发服务器
  devServer: {
    // 模块热替换
    hotOnly: true,
    open: true,
    // 端口
    port: 3001,
    // 额外资源
    contentBase: path.join(__dirname, 'public')
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin()
  ]
})